var e = {
    "[微笑]": 14,
    "[撇嘴]": 1,
    "[色]": 2,
    "[发呆]": 3,
    "[得意]": 4,
    "[流泪]": 5,
    "[害羞]": 6,
    "[大哭]": 9,
    "[尴尬]": 10,
    "[发怒]": 11,
    "[调皮]": 12,
    "[龇牙]": 13,
    "[惊讶]": 0,
    "[难过]": 15,
    "[冷汗]": 17,
    "[抓狂]": 18,
    "[偷笑]": 20,
    "[可爱]": 21,
    "[白眼]": 22,
    "[傲慢]": 23,
    "[困]": 25,
    "[惊恐]": 26,
    "[流汗]": 27,
    "[憨笑]": 28,
    "[奋斗]": 30,
    "[咖啡]": 35,
    "[鲜花]": 36,
    "[爱心]": 37,
    "[拥抱]": 38,
    "[强]": 39,
    "[握手]": 40,
    "[胜利]": 41,
    "[抱拳]": 42,
    "[拳头]": 43,
    "[OK]": 44
}, n = {
    0: [ "[惊讶]", "./emjor/15.png" ],
    1: [ "[撇嘴]", "./emjor/2.png" ],
    2: [ "[色]", "./emjor/3.png" ],
    3: [ "[发呆]", "./emjor/4.png" ],
    4: [ "[得意]", "./emjor/5.png" ],
    5: [ "[流泪]", "./emjor/6.png" ],
    6: [ "[害羞]", "./emjor/7.png" ],
    9: [ "[大哭]", "./emjor/10.png" ],
    10: [ "[尴尬]", "./emjor/11.png" ],
    11: [ "[发怒]", "./emjor/12.png" ],
    12: [ "[调皮]", "./emjor/13.png" ],
    13: [ "[龇牙]", "./emjor/14.png" ],
    14: [ "[微笑]", "./emjor/1.png" ],
    15: [ "[难过]", "./emjor/16.png" ],
    17: [ "[冷汗]", "./emjor/18.png" ],
    18: [ "[抓狂]", "./emjor/19.png" ],
    20: [ "[偷笑]", "./emjor/21.png" ],
    21: [ "[可爱]", "./emjor/22.png" ],
    22: [ "[白眼]", "./emjor/23.png" ],
    23: [ "[傲慢]", "./emjor/24.png" ],
    25: [ "[困]", "./emjor/26.png" ],
    26: [ "[惊恐]", "./emjor/27.png" ],
    27: [ "[流汗]", "./emjor/28.png" ],
    28: [ "[憨笑]", "./emjor/29.png" ],
    30: [ "[奋斗]", "./emjor/31.png" ],
    35: [ "[咖啡]", "./emjor/61.png" ],
    36: [ "[鲜花]", "./emjor/64.png" ],
    37: [ "[爱心]", "./emjor/67.png" ],
    38: [ "[拥抱]", "./emjor/79.png" ],
    39: [ "[强]", "./emjor/80.png" ],
    40: [ "[握手]", "./emjor/82.png" ],
    41: [ "[胜利]", "./emjor/83.png" ],
    42: [ "[抱拳]", "./emjor/84.png" ],
    43: [ "[拳头]", "./emjor/86.png" ],
    44: [ "[OK]", "./emjor/90.png" ],
    "": []
};

module.exports = {
    emotions: n,
    emotionDataIndexs: e,
    parseTextMessage: function(p) {
        var r = /\[[^[\]]{1,3}\]/gm, o = p.match(r), g = [];
        return o && o.length > 0 ? o.forEach(function(r, m) {
            var t = p.substring(0, p.indexOf(r)), j = p.indexOf(r) + r.length, s = e[r], x = n[s];
            t && g.push({
                type: "text",
                text: t
            }), x ? g.push({
                type: "img",
                text: x[0],
                url: x[1]
            }) : g.push({
                type: "text",
                text: r
            }), p = p.substring(j), m === o.length - 1 && p && g.push({
                type: "text",
                text: p
            });
        }) : g.push({
            type: "text",
            text: p
        }), g;
    }
};